﻿using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

/// <summary>
/// Summary description for SendNewsletterEmail
/// </summary>
public class SendNewsletterEmail
{
    public void sendNewsletter(String html, int LibraryID) 
    {
        DatabaseAccess accessor = new DatabaseAccess();

        DataTable people = accessor.getPeopleWhoWantNewsletter(LibraryID).Tables[0];

        sendEmail.EmailService mailer = new sendEmail.EmailService();
        for (int i = 0; i < people.Rows.Count;i++ )
        {
            mailer.sendEmail((String)people.Rows[i].ItemArray[8], "Newsletter", html);
        }
        
    }
    
    public DataTable compileEvents(int LibraryID)
    {
        DatabaseAccess accessor = new DatabaseAccess();
        
        return accessor.compileEvents(LibraryID).Tables[0];
    }
    public DataTable compileAnnouncements(int LibraryID)
    {
        DatabaseAccess accessor = new DatabaseAccess();

        return accessor.compileAnnouncements(LibraryID).Tables[0];
    }    
}
